<!--

    Copyright (c) 2005, 2018 Oracle and/or its affiliates. All rights reserved.
    Portions Copyright &#169; [2017-2020] Payara Foundation and/or affiliates.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<p><a id="task-jdbcconnectionpooladvance" name="task-jdbcconnectionpooladvance"></a><a id="GHJDB00038" name="GHJDB00038"></a></p>

<h4><a id="sthref19" name="sthref19"></a>To Edit JDBC Connection Pool Advanced Attributes</h4>
<a name="BEGIN" id="BEGIN"></a>
<ol>
<li>
<p>In the navigation tree, expand the Resources node.</p>
</li>
<li>
<p>Under the Resources node, select the JDBC node.</p>
</li>
<li>
<p>Under the JDBC node, select the Connection Pools node.</p>
<p>The Connection Pools page opens.</p>
</li>
<li>
<p>On the Connection Pools page, click the name of the pool that you are editing.</p>
<p>The Edit Connection Pool page opens.</p>
</li>
<li>
<p>On the Edit Connection Pool page, click the Advanced tab.</p>
<p>The Edit Connection Pool Advanced Attributes page opens.</p>
</li>
<li>
<p>In the Statement Timeout field, type the length of time, in seconds, after which abnormally long running queries will be terminated.</p>
<p>Payara Server will set <code>QueryTimeout</code> on the statements created. Set the value to -1 to disable this option. The default value is -1.</p>
</li>
<li>
<p>In the Statement Cache Size field, type the number of statements to be cached using the LRU (Least Recently Used) caching mechanism.</p>
<p>To disable statement caching, specify a value of 0. The default value is 0.</p>
</li>
<li>
<p>In the Init SQL field, type an SQL string to be executed whenever a connection is created (not reused) in the pool.</p>
<p>Execution of this string initializes the state of the connection.</p>
</li>
<li>
<p>In the SQL Trace Listeners field, type a comma-separated list of listener implementation class names to specify that SQL statements executed by applications will be traced.</p>
<p>The listener classes must implement the <code>org.glassfish.api.jdbc.SQLTraceListener</code> interface. Use of listeners enables easy filtering of log messages for the SQL statements and helps administrators analyze the statements.</p>
</li>
<li>
<p>Select the Wrap JDBC Objects Enabled checkbox for applications to get wrapped JDBC objects for <code>Statement</code>, <code>PreparedStatement</code>, <code>CallableStatement</code>, <code>ResultSet</code>, <code>DatabaseMetaData</code>.</p>
<p>This option is enabled by default.</p>
</li>
<li>
<p>Select the Pooling checkbox to enable connection pooling for the pool.</p>
<p>This option is enabled by default.</p>
</li>
<li>
<p>In the Validate At Most Once field, type the amount of time, in seconds, after which a connection is validated at most once.</p>
<p>Setting this attribute to an appropriate value minimizes the number of validation requests by a connection. Default value is 0, which means that the attribute is not enabled.</p>
</li>
<li>
<p>In the Connection Leak Timeout field, type the amount of time, in seconds, to trace connection leaks in a connection pool.</p>
<p>Use this field to detect potential connection leaks by the application. A connection that is not returned back to the pool by the application within the specified period is assumed to be potentially leaking, and a stack trace of the caller is logged. Set the value to 0 to disable connection leak tracing. The default value is 0.</p>
<p>Use this field along with Connection Leak Reclaim to avoid potential connection leaks from the application.</p>
</li>
<li>
<p>Select the Connection Leak Reclaim checkbox to restore leaked connections to the pool after leak connection tracing is complete.</p>
<p>This option is disabled by default.</p>
</li>
<li>
<p>In the Statement Leak Timeout field, type the amount of time, in seconds, to trace statement leaks in a connection pool.</p>
<p>Use this field to detect potential statement leaks by the application. A statement that is not returned back to the pool by the application within the specified period is assumed to be potentially leaking, and a stack trace of the caller is logged. Set the value to 0 to disable statement leak tracing. The default value is 0.</p>
<p>Use this field along with Statement Leak Reclaim to avoid potential statement leaks from the application.</p>
</li>
<li>
<p>Select the Statement Leak Reclaim checkbox to restore leaked statements to the pool after leak statement tracing is complete.</p>
<p>This option is disabled by default.</p>
</li>
<li>
<p>In the Creation Retry Attempts field, type the number of attempts that will be made if there is a failure in creating a new connection.</p>
<p>Set the value to 0 to make no attempts to create the connection again. The default value is 0.</p>
</li>
<li>
<p>In the Retry Interval field, type the interval, in seconds, between two attempts to create a connection.</p>
<p>The default value is 10. This attribute is used only if the value of Creation Retry Attempts is greater than 0.</p>
</li>
<li>
<p>Select the Lazy Association Enabled checkbox to associate a physical connection with a logical collection only when the connection is used.</p>
<p>Connections are disassociated when the transaction is completed and a component method ends, which helps reuse of the physical connections. If this option is disabled, a physical connection is associated with a logical connection even before it is used. This option is disabled by default.</p>
</li>
<li>
<p>Select the Lazy Connection Enlistment Enabled checkbox to enlist a resource to the transaction only when it is actually used in a method.</p>
<p>This option is disabled by default.</p>
</li>
<li>
<p>Select the Associate with Thread Enabled checkbox to create associations between connections and threads.</p>
<p>When the same thread is in need of another connection, it can reuse the connection already associated with that thread, thereby not incurring the overhead of getting another connection from the pool. This option is disabled by default.</p>
</li>
<li>
<p>Select the Match Connections Enabled checkbox to enable connection matching for the pool.</p>
<p>If this option is enabled, a connection that is selected from the pool should be matched with connections that have certain credentials. This option must be enabled if the connection pool is used by applications that have multiple user credentials. This option can be disabled if the administrator knows that the connections in the pool will always be homogeneous and therefore a connection picked from the pool does not need to be matched by the resource adapter. This option is disabled by default.</p>
</li>
<li>
<p>In the Max Connection Usage field, type the number of times a connection should be reused by the pool.</p>
<p>Once a connection is reused for the specified number of times, it will be closed. By limiting the number of times a connection can be reused, you can avoid statement leaks if an application does not close statements. Set the value to 0 disable this attribute. The default value is 0.</p>
</li>
<li>
<p>Select the Connection Validation Required checkbox to enable connection validation.</p>
<p>Connection validation allows the server to reconnect in case of failure.</p>
</li>
<li>
<p>From the Validation Method drop-down list, select a validation method.</p>
<p>Payara Server can validate database connections in the following ways.</p>
<dl>
<dt><code>auto-commit</code> and <code>metadata</code></dt>
<dd>
<p>Payara Server validates a connection by calling the <code>con.getAutoCommit</code> and <code>con.getMetaData</code> methods.</p>

<hr>
<p><b>Note:</b></p>
<p>Many JDBC drivers cache the results of these calls. As a result, using these calls might not always provide reliable validations. Check with the driver vendor to determine whether these calls are cached or not.</p>

<hr>

</dd>
<dt><code>custom-validation</code></dt>
<dd>
<p>Payara Server uses a user-defined validation mechanism specified by the custom implementation class in the Validation Classname field.</p>
</dd>
<dt><code>table</code></dt>
<dd>
<p>The application queries the database table that is specified. The table must exist and be accessible, but it does not require any rows. Do not use an existing table that has a large number of rows, or a table that is already frequently accessed.</p>
</dd>
</dl>
</li>
<li>
<p>If you selected <code>table</code> from the Validation Method drop-down list, type the name of the database table or select it from the Table Name drop-down list.</p>
</li>
<li>
<p>If you selected <code>custom-validation</code> from the Validation Method drop-down list, type the custom validation implementation class name or select it from the Validation Class Name drop-down list.</p>
<p>The class name provided must be accessible to Payara Server. The specified class must implement the <code>org.glassfish.api.jdbc.ConnectionValidation</code> interface.</p>
</li>
<li>
<p>Select the On Any Failure Close All Connections checkbox to have the server close and reestablish all connections in the pool in the event of a single connection failure.</p>
<p>If this option is disabled, individual connections are reestablished only when they are used. This option is disabled by default.</p>
</li>
<li>
<p>Select the Allow Non Component Callers Enabled checkbox to allow the pool to be used by non-component callers such as servlet filters and third-party persistence managers.</p>
<p>Connections obtained by non-component callers are not automatically closed at the end of a transaction by the container. They must be explicitly closed by the caller. This option is disabled by default.</p>
</li>
<li>
<p>Click the Flush button on the General tab to flush all connections from the pool.</p>
<p>Clicking the Flush button destroys any existing connections, recreates connections established for the pool, and restores the pool to its initial and minimum pool size.</p>
</li>
<li>
<p>Click Save.</p>

<hr>
<p><b>Tip:</b></p>
<p>To return to the default settings, click the Load Defaults button, then click Save.</p>

<hr>

</li>
</ol>
<a id="sthref20" name="sthref20"></a>
<h5>See Also</h5>
<ul>
<li>
<p><a href="task-setdbaccess.html">To Set Up Database Access</a></p>
</li>
<li>
<p><a href="task-integratejdbcdriver.html">To Integrate a JDBC Driver</a></p>
</li>
<li>
<p><a href="task-jdbcresourcenew.html">To Create a JDBC Resource</a></p>
</li>
<li>
<p><a href="task-jdbcresourcesedit.html">To Edit a JDBC Resource</a></p>
</li>
<li>
<p><a href="task-jdbcresourcetargets.html">To Edit JDBC Resource Targets</a></p>
</li>
<li>
<p><a href="task-jdbcresourcesdelete.html">To Delete a JDBC Resource</a></p>
</li>
<li>
<p><a href="task-jdbcconnectionpoolnew.html">To Create a JDBC Connection Pool</a></p>
</li>
<li>
<p><a href="task-jdbcconnectionpooledit.html">To Edit JDBC Connection Pool General Settings</a></p>
</li>
<li>
<p><a href="task-verifyconnpoolsettings.html">To Verify Connection Pool Settings</a></p>
</li>
<li>
<p><a href="task-jdbcconnectionpoolproperty.html">To Edit JDBC Connection Pool Properties</a></p>
</li>
<li>
<p><a href="task-jdbcconnectionpooldelete.html">To Delete a JDBC Connection Pool</a></p>
</li>
</ul>


<small>Copyright &#169; 2005, 2017, Oracle and/or its affiliates. All rights reserved. <a href="docinfo.html">Legal Notices</a></small>
<small>Portions Copyright &#169; [2017-2020] Payara Foundation and/or affiliates.</small>
